home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / tcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  7.6 KB  |  340 lines

  1. /*          System dependencies in the W3 library
  2.                    SYSTEM DEPENDENCIES
  3.  
  4.    System-system differences for TCP include files and macros. This
  5.    file includes for each system the files necessary for network and
  6.    file I/O.
  7.  
  8.   AUTHORS
  9.  
  10.   TBL             Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
  11.   EvA              Eelco van Asperen <evas@cs.few.eur.nl>
  12.   MA              Marc Andreessen NCSA
  13.   AT              Aleksandar Totic <atotic@ncsa.uiuc.edu>
  14.   SCW              Susan C. Weber <sweber@kyle.eitech.com>
  15.   MJW              Michael J Witbrock <witbrock@cmu.edu>
  16.   MWM              Mike Meyer  <mwm@contessa.phone.net>
  17.  
  18.   HISTORY:
  19.   22 Feb 91          Written (TBL) as part of the WWW library.
  20.   16 Jan 92          PC code from EvA
  21.   22 Apr 93          Merged diffs bits from xmosaic release
  22.   29 Apr 93          Windows/NT code from SCW
  23.  
  24.   Much of the cross-system portability stuff has been intentionally
  25.   REMOVED from this version of the library by Marc A in order to
  26.   discourage attempts to make "easy" ports of Mosaic for X to non-Unix
  27.   platforms.  The library needs to be rewritten from the ground up; in
  28.   the meantime, Unix is *all* we support or intend to support with
  29.   this set of source code.
  30.  
  31. */
  32.  
  33. #ifndef TCP_H
  34. #define TCP_H
  35.  
  36. /*
  37.  
  38. Default values
  39.  
  40.    These values may be reset and altered by system-specific sections
  41.    later on.  there are also a bunch of defaults at the end .
  42.  
  43.  */
  44. /* Default values of those: */
  45. #define NETCLOSE close        /* Routine to close a TCP-IP socket     */
  46. #define NETREAD  HTDoRead    /* Routine to read from a TCP-IP socket     */
  47. #define NETWRITE write        /* Routine to write to a TCP-IP socket    */
  48.  
  49. /* Unless stated otherwise, */
  50. #define SELECT            /* Can handle >1 channel.        */
  51. #define GOT_SYSTEM        /* Can call shell with string        */
  52.  
  53. #ifdef unix
  54. #define GOT_PIPE
  55. #endif
  56.  
  57. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  58.  
  59.  
  60. #ifndef STDIO_H
  61. #include <stdio.h>
  62. #define STDIO_H
  63. #endif
  64.  
  65. #ifdef _AIX
  66. #define AIX
  67. #endif
  68. #ifdef AIX
  69. #define unix
  70. #endif
  71.  
  72. #ifdef _IBMR2
  73. #define USE_DIRENT        /* sys V style directory open */
  74. #endif
  75.  
  76. /* Solaris. */
  77. #if defined(sun) && defined(__svr4__)
  78. #define USE_DIRENT        /* sys V style directory open */
  79. #endif
  80.  
  81. #if defined(__alpha)
  82. #define USE_DIRENT
  83. #endif
  84.  
  85. #ifndef USE_DIRENT
  86. #ifdef SVR4
  87. #define USE_DIRENT
  88. #endif
  89. #endif /* not USE_DIRENT */
  90.  
  91. #include <string.h>        /* For bzero etc */
  92.  
  93. /* Use builtin strdup when appropriate. */
  94. #if defined(ultrix) || defined(VMS) || defined(NeXT)
  95. extern char *strdup ();
  96. #endif
  97.  
  98.  
  99.  
  100. /*
  101.  
  102. VAX/VMS
  103.  
  104.    Under VMS, there are many versions of TCP-IP. Define one if you do
  105.    not use Digital's UCX product:
  106.  
  107.   UCX              DEC's "Ultrix connection" (default)
  108.   WIN_TCP          From Wollongong, now GEC software.
  109.   MULTINET          From SRI, now from TGV Inv.
  110.   DECNET          Cern's TCP socket emulation over DECnet
  111.  
  112.    The last three do not interfere with the
  113.    unix i/o library, and so they need special calls to read, write and
  114.    close sockets. In these cases the socket number is a VMS channel
  115.    number, so we make the @@@ HORRIBLE @@@ assumption that a channel
  116.    number will be greater than 10 but a unix file descriptor less than
  117.    10.    It works.
  118.  
  119.  */
  120. #ifdef vms
  121. #ifdef WIN_TCP
  122. #undef NETREAD
  123. #undef NETWRITE
  124. #undef NETCLOSE
  125. #define NETREAD(s,b,l)    ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  126. #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  127. #define NETCLOSE(s)    ((s)>10 ? netclose(s) : close(s))
  128. #endif
  129.  
  130. #ifdef MULTINET
  131. #undef NETCLOSE
  132. #undef NETREAD
  133. #undef NETWRITE
  134. #define NETREAD(s,b,l)    ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  135. #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
  136.                 write((s),(b),(l)))
  137. #define NETCLOSE(s)    ((s)>10 ? socket_close(s) : close(s))
  138. #endif
  139.  
  140. /*    Certainly this works for UCX and Multinet; not tried for Wollongong
  141. */
  142. #ifdef MULTINET
  143. #include "multinet_root:[multinet.include.sys]types.h"
  144. #include "multinet_root:[multinet.include]errno.h"
  145. #include "multinet_root:[multinet.include.sys]time.h"
  146. #else
  147. #include types
  148. #include errno
  149. #include time
  150. #endif /* multinet */
  151.  
  152. #include string
  153.  
  154. #ifndef STDIO_H
  155. #include stdio
  156. #define STDIO_H
  157. #endif
  158.  
  159. #include file
  160.  
  161. #include unixio
  162.  
  163. #define INCLUDES_DONE
  164.  
  165. #ifdef MULTINET  /* Include from standard Multinet directories */
  166. #include "multinet_root:[multinet.include.sys]socket.h"
  167. #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
  168. #define __TIME    /* to avoid double definitions in next file */
  169. #endif
  170. #include "multinet_root:[multinet.include.netinet]in.h"
  171. #include "multinet_root:[multinet.include.arpa]inet.h"
  172. #include "multinet_root:[multinet.include]netdb.h"
  173.  
  174. #else  /* not multinet */
  175. #ifdef DECNET
  176. #include "types.h"  /* for socket.h */
  177. #include "socket.h"
  178. #include "dn"
  179. #include "dnetdb"
  180. /* #include "vms.h" */
  181.  
  182. #else /* UCX or WIN */
  183. #include socket
  184. #include in
  185. #include inet
  186. #include netdb
  187.  
  188. #endif    /* not DECNET */
  189. #endif    /* of Multinet or other TCP includes */
  190.  
  191. #define TCP_INCLUDES_DONE
  192.  
  193. #endif    /* vms */
  194.  
  195.  
  196.  
  197. /*
  198.  
  199. SCO ODT unix version
  200.  
  201.  */
  202.  
  203. #ifdef sco
  204. #include <sys/fcntl.h>
  205. #define USE_DIRENT
  206. #endif
  207.  
  208. /*
  209.  
  210. MIPS unix
  211.  
  212.  */
  213. /* Mips hack (bsd4.3/sysV mixture...) */
  214.  
  215. #ifdef mips
  216. extern int errno;
  217. #endif
  218.  
  219.  
  220. /*
  221.  
  222. Regular BSD unix versions
  223.  
  224.    These are a default unix where not already defined specifically.
  225.  
  226.  */
  227. #ifndef INCLUDES_DONE
  228. #include <sys/types.h>
  229. /* #include <streams/streams.h>         not ultrix */
  230. #include <string.h>
  231.  
  232. #include <errno.h>        /* independent */
  233. #include <sys/time.h>        /* independent */
  234. #include <sys/stat.h>
  235. #include <sys/param.h>
  236. #ifdef _AMIGA
  237. #include <fcntl.h>
  238. #include <limits.h>
  239. #else
  240. #include <sys/file.h>        /* For open() etc */
  241. #endif
  242. #define INCLUDES_DONE
  243. #endif    /* Normal includes */
  244.  
  245. /*            Directory reading stuff - BSD or SYS V
  246. */
  247. #ifdef unix               /* if this is to compile on a UNIX machine */
  248. #define GOT_READ_DIR 1      /* if directory reading functions are available */
  249. #ifdef USE_DIRENT          /* sys v version */
  250. #include <dirent.h>
  251. #define direct dirent
  252. #else
  253. #include <sys/dir.h>
  254. #endif
  255. #if defined(sun) && defined(__svr4__)
  256. #include <sys/fcntl.h>
  257. #include <limits.h>
  258. #endif
  259. #endif
  260.  
  261. /* This stuff comes BEFORE the defaults below */
  262.  
  263. #ifdef _AMIGA     /* MJW */
  264. #ifndef _DNET
  265.  #ifndef _AS225
  266.   #undef NETREAD
  267.   #undef NETWRITE
  268.   #undef NETCLOSE
  269.   #define NETREAD(s,b,l)  (recv((s),(b),(l),0))
  270.   #define NETWRITE(s,b,l) (send((s),(b),(l),0))
  271.   #define NETCLOSE(s)      (CloseSocket(s))
  272.  #else      /* MWM */
  273.   #undef NETREAD
  274.   #undef NETWRITE
  275.   #undef NETCLOSE
  276.   #define NETREAD(s,b,l)  (recv((s),(b),(l),0))
  277.   #define NETWRITE(s,b,l) (send((s),(b),(l),0))
  278.   #define NETCLOSE(s)      (s_close(s))
  279.   #define IoctlSocket    s_ioctl
  280.   #define _STRICT_ANSI 1
  281.   #include <exec/types.h>
  282.   #include <sys/ioctl.h>
  283.   #include <sys/time.h>
  284.   #include <proto/socket.h>
  285.   #include <netdb.h>
  286.   #include <errno.h>
  287.   #define INCLUDES_DONE
  288.   #define TCP_INCLUDES_DONE
  289.   #define sleep(t) Delay(50*(t))
  290.  #endif /* _AS225 */
  291. #else /* _DNET */
  292.  #include "dnet.h"
  293.  #define TCP_INCLUDES_DONE
  294.  #define ENOTCONN -1
  295.  #define ECONNRESET -1
  296.  #undef NETREAD
  297.  #undef NETWRITE
  298.  #undef NETCLOSE
  299.  #define NETREAD  DRead
  300.  #define NETWRITE DWrite
  301.  #define NETCLOSE DClose
  302. #define sleep(t) Delay(50*(t))
  303. #endif /* _DNET */
  304. #endif    /* _AMIGA */
  305.  
  306. /*
  307.  
  308. Defaults
  309.  
  310.   INCLUDE FILES FOR TCP
  311.  
  312.  */
  313. #ifndef TCP_INCLUDES_DONE
  314. #include <sys/ioctl.h> /* EJB */
  315. #include <sys/socket.h>
  316. #include <netinet/in.h>
  317. #ifndef __hpux /* this may or may not be good -marc */
  318. #include <arpa/inet.h>        /* Must be after netinet/in.h */
  319. #endif
  320. #include <netdb.h>
  321. #endif    /* TCP includes */
  322.  
  323.  
  324. /*
  325.  
  326.   MACROS FOR MANIPULATING MASKS FOR SELECT()
  327.  
  328.  */
  329. #ifdef SELECT
  330. #ifndef FD_SET
  331. typedef unsigned int fd_set;
  332. #define FD_SET(fd,pmask) (*(pmask)) |=    (1<<(fd))
  333. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  334. #define FD_ZERO(pmask)     (*(pmask))=0
  335. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  336. #endif    /* FD_SET */
  337. #endif    /* SELECT */
  338.  
  339. #endif /* TCP_H */
  340.